import { $http } from '@/utils';
import { $ResponseCode } from '@/utils/const/env';
export const Mch = {
    info: () => {
        return new Promise((resolve, reject) => {
            $http.get('Mch/info').then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    apply:(data:any) => {
        return new Promise((resolve, reject) => {
            $http.post('Mch/apply', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    deleteImage(data: any) {
        return new Promise((resolve, reject) => {
            $http.post('Mch/deleteImage', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    details: (mch_id: any) => {
        return new Promise((resolve, reject) => {
            $http.get('Mch/details', {
                data: {
                    mch_id
                }
            }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    }
}